#####
#S7 - This computes tables for Supplementary Materials part 7
#This compares weighted and unweighted results

#unweighted
#percentage in unweighted saying shooter is justified
J<-table(n$justified)[2]/3145

#make xtabs of correct/justified
JCT<-xtabs(~n$CORRECT+n$justified)

#compute % saying justified|Correct, Incorrect
JIC<-(JCT[1,2]/sum(JCT[1,]))
JC<-(JCT[2,2]/sum(JCT[2,]))

#Bind together
S7AC4<-rbind(J,JC,JIC)

#Unweighted - find % saying strongly support shooter
S<-table(n$SSSW)[2]/3145

#make xtabs of strongly support, correct
SCT<-xtabs(~n$CORRECT+n$SSSW)

#find % saying strongly support shooter|correct, incorrect
SIC<-(SCT[1,2]/sum(SCT[1,]))
SC<-(SCT[2,2]/sum(SCT[2,]))

#bind results together
S7AC5<-rbind(S,SC,SIC)

#Unweighted - find % saying weakly support shooter
W<-table(n$WSW)[2]/3145

#make xtabs 
WCT<-xtabs(~n$CORRECT+n$WSW)

#find % saying weakly support shooter|correct, incorrect
WIC<-(WCT[1,2]/sum(WCT[1,]))
WC<-(WCT[2,2]/sum(WCT[2,]))

#Pull together all Weak Support
S7AC6<-rbind(W,WC,WIC)

#Bring together as unweighted
T3UW<-cbind(S7AC4,S7AC5,S7AC6)

#round for clarity
T3UW<-round(T3UW,4)

#rename columns for clarity
colnames(T3UW)<-c("Unweighted - Justified","Unweighted - Strongly Support Shooter","Unweighted - Weakly Support Shooter")

#select similar weights from weighted, 
#computed in code in T3.r
T3W<-T3[c(1:3),]

#Bring together weighted, unweighted
S7<-cbind(T3W,T3UW)

#write out reults
write.csv(S7,"../Supplementary Results/TableS7.csv")







